﻿/********************************************************************
	created:	2011-8-17   2:03
	author:		Lifan Su
	
	purpose:	Interface of SHA-224 functions.
*********************************************************************/

#ifndef SHA224_H
#define SHA224_H

#include "crypt_hash_common.h"

#ifdef __cplusplus
extern "C" {
#endif

    //  data only
    struct SHA224_d {
        uint32_t    hash[7];
    };

    //  stream with statue
    struct SHA224_c {
        uint32_t    hash[8];

        uint8_t     buffer[64];

        uint64_t    length;
        uint8_t     append;
    };

    //  from big-endian, as hex print in hashcalc
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_d_read(struct SHA224_d *, const void *);

    //  to big-endian, as hex print in hashcalc
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_d_write(void *, const struct SHA224_d *);

    //  print, at least 57 char shall be provided
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_d_print(char *, const struct SHA224_d *);
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_d_printw(wchar_t *, const struct SHA224_d *);

    //  comp
    CRYPT_HASH_PREFIX uint8_t CRYPT_HASH_API sha224_d_less(const struct SHA224_d *, const struct SHA224_d *);
    CRYPT_HASH_PREFIX uint8_t CRYPT_HASH_API sha224_d_eq(const struct SHA224_d *, const struct SHA224_d *);

    //  convert
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_cvt(struct SHA224_d *, const struct SHA224_c *);

    //  init
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_c_init(struct SHA224_c *);

    //  append
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_c_append(struct SHA224_c *, const void *, uint64_t);

    //  close
    CRYPT_HASH_PREFIX void CRYPT_HASH_API sha224_c_close(struct SHA224_c *);

#ifdef __cplusplus
}
#endif


#endif // SHA224_H